package com.example.demo;

import android.app.Application;
import android.content.Context;
//提供全局的上下文对象
public class MyApplication extends Application {

    private static Context context;

    @Override
    public void onCreate() {
        super.onCreate();
        context = getApplicationContext();  // 获取全局上下文
    }

    public static Context getContext() {
        return context;  // 返回全局上下文
    }
}
